#define _CRT_SECURE_NO_WARNINGS 1

#include "SeqList.h"

void TestSeqList1()
{
	SListNode* plist = NULL;

	int arr1[] = { 1,2,3,4,5 };
	int i = 0;
	int sz1 = sizeof(arr1) / sizeof(arr1[0]);

	for (i = 0; i < sz1; ++i)
	{
		SeqListPushBack(&plist, arr1[i]);
	}

	SeqListPrint(plist);

	int arr2[] = { 1,2,3,4,5 };
	int sz2 = sizeof(arr2) / sizeof(arr2[0]);

	for (i = 0; i < sz2; ++i)
	{
		SeqListPushFront(&plist, arr2[i]);
	}

	SeqListPrint(plist);

	SeqListDestroy(&plist);
}

void TestSeqList2()
{
	SListNode* plist = NULL;

	SeqListPushBack(&plist, 1);
	SeqListPushBack(&plist, 2);
	SeqListPushBack(&plist, 3);

	SeqListPrint(plist);

	SeqListPopFront(&plist);
	SeqListPrint(plist);
	SeqListPopFront(&plist);
	SeqListPrint(plist);
	SeqListPopFront(&plist);
	SeqListPrint(plist);

	SeqListDestroy(&plist);
}

void TestSeqList3()
{
	SListNode* plist = NULL;

	SeqListPushBack(&plist, 1);
	SeqListPushBack(&plist, 2);
	SeqListPushBack(&plist, 3);
	SeqListPrint(plist);

	SListNode* ret1 = SeqListFind(plist, 1);
	if (ret1)
	{
		SeqListInsertAfter(ret1, 0);
	}

	SListNode* ret2 = SeqListFind(plist, 2);
	if (ret2)
	{
		SeqListInsertAfter(ret2, 0);
	}

	SListNode* ret3 = SeqListFind(plist, 3);
	if (ret3)
	{
		SeqListInsertAfter(ret3, 0);
	}
	SeqListPrint(plist);

	ret1 = SeqListFind(plist, 1);
	if (ret1)
	{
		SeqListEraseAfter(ret1);
	}
	SeqListPrint(plist);

	ret2 = SeqListFind(plist, 2);
	if (ret2)
	{
		SeqListEraseAfter(ret2);
	}
	SeqListPrint(plist);

	ret3 = SeqListFind(plist, 3);
	if (ret3)
	{
		SeqListEraseAfter(ret3);
	}
	SeqListPrint(plist);
	
	SeqListDestroy(&plist);
}

int main()
{
	//TestSeqList1();
	//TestSeqList2();
	TestSeqList3();
	return 0;
}